#include <array>
#include <iostream>
#include <iterator>

using namespace std;


int sum_arr(int array[], int len_array);

int* multi_arr(int arr[], int len_array, int alpha)
{
	for (int i=0; i < len_array; i ++)
	{
		arr[i] *= alpha;
	}
	return arr;
}

int const_test(const int arr[], int len_array)
{
//	arr[0] = -1;
	return arr[0];
}

void print_arr(int array[], int len_array)
{
	for (int i=0; i<len_array; i++)
	{
		cout << array[i] << " ";
	}
	cout << "\n";
}


int main()
{
	int arr[4] = {1,4,7,2};
	int result = sum_arr(arr, 4);
	cout << "sum: " << result << endl;
	
	cout << "raw arr \n";
	print_arr(arr, 4);

	int* np = multi_arr(arr, 4, 2);
	cout << "print new pointer \n";

	print_arr(np, 4);
	
	cout << "print original pointer \n";
	print_arr(arr, 4);
}

int sum_arr(int array[], int len_array)
{
	int tmp = 0;
	/********************
	for (int i: array)
	{
		tmp += i;
	}
	此时为动态数组，不能使用基于范围的for循环
	********************/

	for (int i=0; i < len_array; i ++)
	{
		tmp += array[i];
	}
	return tmp;
}
